import request from '@/api/request'

/**获取购物车列表 */
export const shoppingList = () =>
  request({
    url: `/api/shopping-cart/list`,
    method: 'get',
  })

/**删除商品 */
export const deletes = ({ id }) =>
  request({
    url: `/api/shopping-cart/del`,
    data: {
      id,
    },
    method: 'POST',
  })

/**删除选中商品 */
export const deleteSelect = ({ ids }) =>
  request({
    url: `/api/shopping-cart/dels`,
    data: {
      ids,
    },
    method: 'POST',
  })

/**选中商品*/
export const syncSelected = ({ id, selected }) =>
  request({
    url: `/api/shopping-cart/select`,
    params: {
      id,
      selected,
    },
    method: 'GET',
  })

/**修改购物车商品数量 */
export const syncNumber = ({ id, number }) =>
  request({
    url: `/api/shopping-cart/number`,
    params: {
      id,
      number,
    },
    method: 'GET',
  })

/**获取购物车商品数量 */
export const shoppingCount = () =>
  request({
    url: `/api/shopping-cart/count`,
    method: 'get',
  })

/**新增购物车条目 */
export const shoppingAdd = ({ number, commodityid, specification }) =>
  request({
    url: `/api/shopping-cart/add`,
    data: {
      number,
      commodityid,
      specification,
    },
    method: 'post',
  })

/**结算 */
export const shoppingSettle = ({ ids }) =>
  request({
    url: `/api/shopping-cart/settle`,
    data: {
      ids,
    },
    method: 'post',
  })

/**待评价 */
export const shoppingSettled = () =>
  request({
    url: `/api/shopping-cart/settled`,
    method: 'get',
  })

/**从id获取 */
export const shoppingFromid = ({ id }) =>
  request({
    url: `/api/shopping-cart/fromid`,
    method: 'get',
    params: { id },
  })
